import { isRef,onDeactivated } from "vue";


/**
 * 监听滚动条
 * @param {*需要监听的元素} el 
 * @param {*回调函数} callback 
 * @returns 
 */
export function ListenerScroll(el, callback) {
    const isV = isRef(el)
    if(!el || (isV && !el.value)) return
    el.value.addEventListener('scroll', callback, true)

    onDeactivated(() =>{
        el.value.removeEventListener('scroll', callback, true)
    })
}